﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Json;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace JsonViewer.Converters
{
    public class JsonValueToJsonNodeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            JsonNode jsonNode = value as JsonNode;

            if (jsonNode != null)
            { 
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        private void TraversalJsonNode(JsonNode jsonNode)
        {

        }

        private JsonNode TranslationJsonObject(string propertyName, JsonObject jsonObject)
        {
            JsonNode jsonNode = new JsonNode()
            {
                PropertyName = propertyName
            };

            jsonNode.Children = new ObservableCollection<JsonNode>();

            foreach (KeyValuePair<string, JsonValue> keyValue in jsonObject)
            {
                jsonNode.Children.Add(new JsonNode()
                {
                    PropertyName = keyValue.Key,
                    PropertyValue = keyValue.Value
                });
            }

            return jsonNode;
        }

        private JsonNode TranslationJsonArray(string propertyName, JsonArray jsonArray)
        {
            JsonNode jsonNode = new JsonNode()
            {
                PropertyName = propertyName
            };

            jsonNode.Children = new ObservableCollection<JsonNode>();

            foreach (var jsonValue in jsonArray)
            {
                //  KeyValuePair 

            }

            return jsonNode;
        }
    }
}
